/*
 * @Author: 一日看尽长安花
 * @since: 2019-10-14 17:36:16
 * @LastEditTime: 2019-10-18 16:25:37
 * @LastEditors: 一日看尽长安花
 * @Description:
 */
import Mock from 'mockjs';
export default [
  {
    url: '/tables/metedata',
    type: 'get',
    response: config => {
      return {
        code: 200,
        data: {
          date: {
            name: '日期',
            sortable: true,
            type: 'Date',
            required: true,
            visible: false
          },
          name: {
            name: '名字',
            sortable: true,
            type: 'String',
            required: true,
            visible: false
          },
          address: {
            name: '地址',
            sortable: true,
            type: 'String',
            required: false,
            visible: false
          },
          url: {
            name: '网址',
            sortable: true,
            type: 'String',
            required: false,
            visible: false
          }
        }
      };
    }
  },
  {
    url: '/tables',
    type: 'get',
    response: config => {
      const { page, limit } = { ...config.query };
      const List = [];
      const tempPage = !page ? 1 : page;
      const count = !limit ? 10 : limit;
      for (let i = 0; i < count; i++) {
        List.push(
          Mock.mock({
            id: Mock.Random.id(),
            date: Mock.Random.datetime(),
            name: Mock.Random.cname(),
            address: Mock.Random.region() + ' ' + Mock.Random.county(true),
            url: Mock.Random.url()
          })
        );
      }

      return {
        code: 200,
        data: {
          data: List,
          total: 200
        }
      };
    }
  },
  {
    url: '/tables',
    type: 'post',
    response: config => {
      const { page, limit } = { ...config.query };

      return {
        code: 200,
        data: {
          message: 'Successly create data'
        }
      };
    }
  },
  {
    url: '/tables',
    type: 'put',
    response: config => {
      const { page, limit } = { ...config.query };

      return {
        code: 200,
        data: {
          message: 'Successly update data'
        }
      };
    }
  }
];
